//
// Created by CodeZijun on 2022/12/4.
//

#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;
#ifndef DATASTRUCTURES_HAFFMAN_H
#define DATASTRUCTURES_HAFFMAN_H

struct haffmanNode{
    haffmanNode* l_child;
    haffmanNode* r_child;
    pair<int,string> p;
    haffmanNode(int w, string data){
        l_child = nullptr;
        r_child = nullptr;
        p.first = w;
        p.second = data;
    }
    haffmanNode(){
        l_child = nullptr;
        r_child = nullptr;
        p.first = -1;
        p.second = "";
    }
};

class haffman {
public:
    haffmanNode* root;
    int WPL;
    void produceHaffManTree();
    int calWPL(haffmanNode* p);
    haffman(){
        root = nullptr;
        WPL = 0;
    }
    string decipher(string code);
};


#endif //DATASTRUCTURES_HAFFMAN_H
